package com.laizhenghua.wxstub.entiry;

import com.laizhenghua.wxstub.dto.WxUserDTO;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;

/**
 * @description:
 * @author: laizhenghua
 * @date: 2022/9/8 21:07
 */
public class LoginUser implements UserDetails {
    private static final long serialVersionUID = -806664095933164608L;
    private WxUserDTO user;

    public LoginUser(WxUserDTO user) {
        this.user = user;
    }
    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return null;
    }

    @Override
    public String getPassword() {
        return user.getPassword();
    }

    @Override
    public String getUsername() {
        return user.getWxId();
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    public WxUserDTO getUser() {
        return user;
    }

    public void setUser(WxUserDTO user) {
        this.user = user;
    }
}
